package com.yneusoft.manage.controller;

import com.yneusoft.common.model.ResponseWrapper;
import com.yneusoft.manage.model.param.UserLoginParam;
import com.yneusoft.manage.service.LoginManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * @author lt
 * @date 2021/10/20 19:05
 * @description: 登录模块接口
 */
@RestController
public class LoginManageController {
    @Autowired
    private LoginManageService loginManageService;

    /**
     * 1、获取图片验证码
     *
     * @return imageCodeKey imageCodeBase64
     */
    @GetMapping("/loginManage/getImageCode")
    public ResponseWrapper getImageCode() {
        return loginManageService.getImageCode();
    }

    /**
     * 2、用户登录
     *
     * @param param 用户登录参数
     * @return token、name
     */

    @PostMapping("/loginManage/userLogin")
    public ResponseWrapper userLogin(@RequestBody @Validated UserLoginParam param) {
        return loginManageService.login(param);
    }

    /**
     * 3、获取当前用户信息
     *
     * @return name
     */
    @GetMapping("/getCurrentUserInfo")
    public ResponseWrapper getUserInfo() {
        return loginManageService.getCurrentUserInfo();
    }
}
